home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / Documentation / Development Notes / 'nmap', Icon, & Part Signature next >
Encoding:
Text File  |  1996-09-19  |  10.5 KB  |  279 lines  |  [TEXT/ttxt]

  1. OpenDoc
  2. Development
  3. Framework
  4.                                                                                                                                                                                     
  5. 'nmap', Icon, & Part Signature 
  6. ODF Release 2                                                                                                                                                            
  7.  
  8. This document provides information about modifying your part's resources.
  9.  
  10.  
  11. Table of Contents
  12. -------------------------
  13. • Why You Need to Change Your Part's Resources
  14. • Modifying Your 'nmap' Resources
  15.    • Kind->Category Mapping
  16.    • Editor->Kind Mapping
  17.    • Editor User String
  18.    • Kind User String
  19.    • Category User String
  20.    • Mac OS Type Mapping
  21.    • Platform Type Mapping
  22. • Changing Your Part Signature
  23. • Changing Your Part Icons
  24.  
  25.  
  26.  
  27. Why You Need to Change Your Part's Resources
  28.  
  29. Whenever you create a part editor, you must supply OpenDoc with a series of 'nmap' resources, which provide OpenDoc with a multitude of information about your part. When you create a new part using PartMaker, you get a set of initial 'nmap' resources, which correspond to the kinds of data supported by the part that was used to generate the PartMaker template. You need to change these resources to reflect the information contained in your part.
  30.  
  31. In addition to the 'nmap' resources, OpenDoc on the Mac OS requires you to specify a unique OSType that corresponds to your part's creator signature. You should also add unique icons for your part so that users can distinguish between your part and others. Changing these two things is a matter of manipulating your 'BNDL' resources and setting the appropriate creator type in your development environment. 
  32.  
  33. You need to replace the creator, file type and stationery type in three files. 
  34.  
  35. 1) In the file Binding.k, change this line:
  36. #define MyContainerOSType 'DFPJ'    ==> 'WXYZ'  (Your File Type)
  37.  
  38. 2) In the file MacMake.bmk, change this line:
  39. __ComponentSignature = 'ODFJ' ==> 'ABCD'  (Your Creator)
  40.  
  41. 3) In the file "Part.r", change four resources:
  42. resource 'FREF' (129) {
  43.     'DFPJ',  ==> 'WXYZ'    (Your File Type)
  44. resource 'FREF' (130) {
  45.     'sFPJ',  ==> 'sXYZ'    (Your Stationery File Type (File Type with 's' as first letter))
  46. resource 'BNDL' (128) {
  47.     'ODFJ',  ==> 'ABCD'  (Your Creator)
  48. data 'ODFJ' (0, "Owner resource")  ==> 'ABCD'  (Your Creator)
  49.  
  50. You should change these identifiers before building your part for the first time. 
  51.  
  52. So the basic checklist of resources to modify is as follows:
  53.  
  54.    - 'nmap' resources
  55.    - Mac OS creator type for the part
  56.    - Mac OS icons for the part
  57.  
  58.  
  59.  
  60. Modifying Your 'nmap' Resources
  61.  
  62. Your part can have several 'nmap' resources, depending on the types of data your part supports and the structure of your part editor. The most commonly used 'nmap' resources are as follows: 
  63.  
  64.    - Kind->Category mapping
  65.    - Editor->Kind mapping
  66.    - Editor User String
  67.    - Kind User String
  68.    - Category User String (only if you do not use an OpenDoc defined category)
  69.    - Mac OS Type mapping
  70.  
  71. In addition, you may want to supply one other type of 'nmap' resource to map platform-types to your part editor, for use during data interchange operations. This Platform Type mapping is described later in this section. 
  72.  
  73. Note: the following examples assume the creation of a sample part called YourPart, which is being developed from a basic PartMaker template. This part supports a custom data format and also supports the data format of another part called SurfPart. This part can also import 'TEXT' and 'PICT' data from standard Mac OS applications.
  74.  
  75. The OpenDoc Developer Release CDs also have documentation that describes how to create 'nmap' resources for your part. See these documents for more information about 'nmap' resources.
  76.  
  77.  
  78. Kind->Category mapping
  79.  
  80. The Kind->Category mapping allows OpenDoc to map the data format(s) defined by your part to a more generic category, such as Text or Graphics. The basic format of this resource looks like the following:
  81.  
  82. resource kODNameMappings (kKindCategoryMapId)
  83. {
  84.     kODKind,
  85.     {
  86.         kYourPartKind, 
  87.         kODIsAnISOStringList 
  88.         {
  89.             {
  90.                 kODCategoryDrawing,
  91.                 kYourNewCategory
  92.             }
  93.         }
  94.     }
  95. }
  96.  
  97. In this example, the kYourPartKind string is an ISO string describing the data format supported by your part. The constant kODCategoryDrawing is defined by OpenDoc as the generic category for object-oriented graphics formats. The kYourNewCategory is a custom category that also describes the part's data. You do not have to support multiple categories in your part, only the ones that make sense for your data.
  98.  
  99. You must change the text of the kYourPartKind string to match the data format your part supports. You must also change category string(s) to match the category(s) that your part's data falls into.
  100.  
  101.  
  102. Editor->Kind mapping
  103.  
  104. The Editor->Kind mapping allows OpenDoc to map your part editor to the data format(s) it supports in its storage unit. The basic format of this resource looks like the following:
  105.  
  106. resource kODNameMappings (kEditorKindMapId)
  107. {
  108.     kODEditorKinds,
  109.     {
  110.         kYourPartEditor, 
  111.         kODIsAnISOStringList 
  112.         {
  113.             {
  114.                 kYourPartKind,
  115.                 kSurfPartKind
  116.             }
  117.         }
  118.     }
  119. }
  120.  
  121. In this example, you would need to change the kYourPartKind string to match your part's data format. Do not change the kYourPartEditor string since PartMaker sets this information correctly when you generate the part.
  122.  
  123. If your part supports multiple data formats, make sure that you list the formats in order of fidelity, starting with your part's native format.
  124.  
  125.  
  126. Editor User String
  127.  
  128. The Editor User String resource allows OpenDoc to map an instance of your part to a user-readable text string. 
  129.  
  130. resource kODNameMappings (kEditorUserStringMapId)
  131. {
  132.     kODEditorUserString,
  133.     {
  134.         kYourPartEditor, 
  135.         kODIsINTLText 
  136.         { 
  137.             smRoman,
  138.             langEnglish,
  139.             kEditorUserString
  140.         }
  141.     }
  142. }
  143.  
  144. In this example, you would need to change the text of the kEditorUserString to identify your part. This text could contain something like "My Part 1.0".
  145.  
  146.  
  147. Kind User String
  148.  
  149. The Kind User String resource allows OpenDoc to map the kinds of data supported by your part to user-readable strings. 
  150.  
  151. resource kODNameMappings (kEditorUserStringMapId)
  152. {
  153.     kODKindUserString,
  154.     {
  155.         kYourPartKind, 
  156.         kODIsINTLText 
  157.         { 
  158.             smRoman,
  159.             langEnglish,
  160.             kYourKindUserString
  161.         }
  162.     }
  163. }
  164.  
  165. In this example, you would need to change the text of the kYourKindUserString to identify your data. This text would contain something like "My Part data". If you hadn't changed the kYourPartKind string already, you would also need to do that.
  166.  
  167.  
  168. Category User String
  169.  
  170. The Category User String resource allows OpenDoc to map the categories supported by your part to user-readable strings. You do not have to specify this resource if your part uses only OpenDoc standard categories.
  171.  
  172. resource kODNameMappings (kEditorUserStringMapId)
  173. {
  174.     kODKindUserString,
  175.     {
  176.         kYourNewCategory, 
  177.         kODIsINTLText 
  178.         { 
  179.             smRoman,
  180.             langEnglish,
  181.             kYourCategoryUserString
  182.         }
  183.     }
  184. }
  185.  
  186. In this example, you would need to change the text of the kYourNewCategory and kYourCategoryUserString since they are specific to your part. You do not need to specify a text string for the kODCategoryDrawing category, since OpenDoc defines this string already.
  187.  
  188.  
  189. Mac OS Type mapping
  190.  
  191. The Mac OS Type mapping allows OpenDoc to map the data formats supported by your part to Mac OS types. The basic format of this resource looks like the following:
  192.  
  193. resource kODNameMappings (kEditorKindMapId)
  194. {
  195.     kODKindOldMacOSType,
  196.     {
  197.         kYourPartKind, 
  198.         kODIsMacOSType 
  199.         {
  200.             kYourPartMacOSType
  201.         },
  202.  
  203.         kSurfPartKind, 
  204.         kODIsMacOSType 
  205.         {
  206.             kSurfPartMacOSType
  207.         },
  208.     }
  209. }
  210.  
  211. In this example, you would need to change the kYourPartMacOSType to match your part's Mac OS type. If you hadn't changed the kYourPartKind string already, you would also need to do that. 
  212.  
  213.  
  214. Platform Type mapping
  215.  
  216. In addition to OpenDoc part types, your part can support types such as 'TEXT' and 'PICT', used by existing applications. To do this, you must create a new 'nmap' resource of the type kODEditorPlatformKind. In this resource, specify the OSType's that your part supports. (You must also specify a user string and category for these types in your resource.) The following example shows how you would support both 'TEXT' and 'PICT' resources.
  217.  
  218. resource kODNameMappings (kEditorPlatformKinds)
  219. {
  220.     kODEditorPlatformKind,
  221.     {
  222.         kYourPartEditor,
  223.         kODIsPltfmTypeSpac
  224.         {
  225.             {
  226.                 /* First type */ 
  227.                 kODPlatformFileType, 
  228.                 kTEXTOSType,
  229.                 smRoman,
  230.                 langEnglish,
  231.                 kDragKindUserString1,
  232.                 kODCategoryPlainText,
  233.  
  234.                 /* Second type */
  235.                 kODPlatformFileType, 
  236.                 kPICTOSType,
  237.                 smRoman,
  238.                 langEnglish,
  239.                 kDragKindUserString2,
  240.                 kODCategoryDrawing
  241.             }
  242.         }
  243.     }
  244. }
  245.  
  246.  
  247.  
  248. Changing Your Part Signature
  249.  
  250. You must define a unique signature that distinguishes your part from other parts. This signature is a four-byte code and is analagous to an application creator type. You specify this signature in your part's 'BNDL' resource and to your development environment when you are building your part. See the documentation that comes with your development environment for setting this signature.
  251.  
  252.  
  253.  
  254. Changing Your Part Icons
  255.  
  256. There are two places where you need to identify your part's icons: your 'BNDL' resource and your Part Info resource. You can modify your 'BNDL' resource in the same way you would for an application. Your Part Info resource is an ODF custom resource that identifies the icon family that OpenDoc uses to display your part as either a large or small icon within a document. 
  257.  
  258. The Part Info resource contains three pieces of information and looks like the following:
  259.  
  260. resource FW_RPartInfo(kPartInfoID)
  261. {
  262.     // ----- Icon ID
  263.     kViewAsIconID,
  264.     
  265.     // ----- Part Name
  266.     kEditorUserString,
  267.     
  268.     // ----- PartKind
  269.     kYourPartKind
  270. };
  271.  
  272. See the ODF Developer's Guide for more information on Part Info resources.
  273.  
  274.  
  275. © 1993 - 1996 Apple Computer, Inc. All rights reserved.
  276. Apple, the Apple Logo, Macintosh, and OpenDoc are trademarks of Apple Computer, Inc., registered in the United States and other countries.